/**
 *
 */
package com.wedroid.r2d2.message.command;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.wedroid.entity.command.Command;
import com.wedroid.entity.command.TemplateType;
import com.wedroid.r2d2.contact.Contact;
import com.wedroid.r2d2.http.RequestManager;

/**
 * @author lute
 */
@Component("textCommandOperator")
public class TextCommandOperator extends TemplateCommandOperator {

    @Autowired
    private RequestManager requestManager;

    /* (non-Javadoc)
     * @see com.wedroid.r2d2.message.command.CommandOperator#supportsCommand(com.wedroid.entity.command.TemplateType)
     */
    public boolean supportsCommand(TemplateType templateType) {
        return TemplateType.TEXT.equals(templateType) ||
                TemplateType.URL.equals(templateType);
    }

    /* (non-Javadoc)
     * @see com.wedroid.r2d2.message.command.TemplateCommandOperator#doOperate(com.wedroid.entity.command.Command, java.lang.String, com.wedroid.r2d2.contact.Contact)
     */
    @Override
    protected void doOperate(Command command, String template, Contact sender) {
        requestManager.sendText(template, sender.getUserName());
    }

}
